/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFParaManager
  \brief a singleton manager class to manage all kinds of parameters globally,
  typically channel id maps, detector positions, calibration constants, and other
  miscellaneous ones.
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-12-03
  \date 2021-12-04 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-12-03   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFParaManager_h
#define ETFParaManager_h

#include <string>
#include <Rtypes.h>

using std::string;

class ETFYaml;

class ETFParaManager{
public:
  static ETFParaManager *Instance();
  virtual ~ETFParaManager();

  const ETFYaml *GetChIdPara() const{ return testnull(fChIdConfig); }
  const ETFYaml *GetDetPosPara() const{ return testnull(fDetPosConfig); }
  const ETFYaml *GetDelayPara() const{ return testnull(fDelayConfig); }
  const ETFYaml *GetMisPara() const{ return testnull(fMisConfig); }

  void SetChIdConfigFile(const string &file){ SetConfigFile(fChIdConfig, file); }
  void SetDetPosConfigFile(const string &file){ SetConfigFile(fDetPosConfig, file); }
  void SetDelayConfigFile(const string &file){ SetConfigFile(fDelayConfig, file); }
  void SetMisConfigFile(const string &file){ SetConfigFile(fMisConfig, file); }

  void SetPXIFile(const string &f){ fPXIFile = f; }
  void SetVMEFile(const string &f){ fVMEFile = f; }
  const string &pxifile() const{ return fPXIFile; }
  const string &vmefile() const{ return fVMEFile; }

  static void SetConfigFile(ETFYaml *&c, const string &file);

  ClassDef(ETFParaManager, 0); ///< parameter manager class for ETFAna

protected:
  ETFParaManager();
  /// check if p is null, and issue a warning if so
  const ETFYaml *testnull(const ETFYaml *p) const;

  static ETFParaManager *fInstance;
  ETFYaml *fChIdConfig; ///< channel id config file
  ETFYaml *fDetPosConfig; ///< detector position config file
  ETFYaml *fDelayConfig; ///< delay calibration constants config file
  ETFYaml *fMisConfig; ///< miscellaneous config file

  /// the raw data files to be passed from terminal to internal function ///
  string fPXIFile, fVMEFile;
};

#endif
